package com.twu.biblioteca;

import java.io.IOException;


public class ReserveBookCommand implements Command {
    Library library = new Library();

    ReserveBookCommand(Library lib){
        library = lib;
    }

    public void performAction() {
        library.printBooks(System.out);
        UserInputHandler userInputHandler = new UserInputHandler(System.in);
        int index;
        try {
            index = userInputHandler.getBookIndex();
            if(library.validateIndex(index)) library.reserveBook(index);
            else System.out.println("Select a valid option!!");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
